﻿using System.ServiceModel;

namespace Cubicle.Core.Interfaces
{
    [ServiceContract(
        Namespace = "http://cubicle.codeplex.com",
        SessionMode = SessionMode.Required,
        CallbackContract = typeof(IClientObserver))]
    public interface ISubscribeContract
    {
        /// <summary>
        /// Subscribe to an observable object handle
        /// </summary>
        /// <param name="handle">The handle of the observable to subscribe to</param>
        /// <param name="reference">
        /// A unique reference to the client. i.e. each cell in Excel could subscribe independently. So this could be: IPaddress:ExcelFile:CellRow:CellColumn
        /// </param>
        [OperationContract(IsOneWay = true)]
        void Subscribe(string handle);

        /// <summary>
        /// Called by the client to unsubscribe a reference from a handle.
        /// </summary>
        /// <param name="handle">The handle of the observable to subscribe to</param>
        /// <param name="reference">
        /// A unique reference to the client. i.e. each cell in Excel could subscribe independently. So this could be: IPaddress:ExcelFile:CellRow:CellColumn
        /// </param>
        [OperationContract(IsOneWay = true)]
        void Unsubscribe(string handle);
    }

    public interface IClientObserver
    {
        [OperationContract(IsOneWay = true)]
        void OnNext(object data);

        [OperationContract(IsOneWay = true)]
        void OnError(string message);

        [OperationContract(IsOneWay = true)]
        void OnComplete();
    }
}